#include "stdafx.h"
#include "GraphicsManager.h"
#include "Preview.h"

#include <algorithm>


#ifdef _DEBUG
#define new DEBUG_NEW
#endif

CGraphicsManager::CGraphicsManager()
: m_pCSGraphics(NULL)
{
}

CGraphicsManager::~CGraphicsManager()
{
}

void CGraphicsManager::Clear()
{
	m_Collection.clear();
	m_Collection.push_back(m_pCSGraphics);
}

void CGraphicsManager::Add(IRender* pObject)
{
	CCoordinateSystemGraphics* pCSGraphics = dynamic_cast<CCoordinateSystemGraphics*>(pObject);
	if (pCSGraphics != NULL)
	{
		m_pCSGraphics = pCSGraphics;
	}

	GraphicsCollection::iterator it = std::find(m_Collection.begin(), m_Collection.end(), pObject);
	if (it == m_Collection.end())
		m_Collection.push_back(pObject);
}